package com.own.compoent.mq.rabbit.consumer.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * FanoutConfig
 *
 * @author chenxueli
 * @date 2023-07-25 08:29:30
 */
@Slf4j
@SpringBootConfiguration
public class FanoutConfig {

    /**
     * 声明队列
     *
     * @return 队列
     */
    @Bean
    public Queue fanoutQ1() {
        return new Queue("fanout.queue1");
    }

    /**
     * 声明exchange
     *
     * @return exchange
     */
    @Bean
    public FanoutExchange setFanoutExchange() {
        return new FanoutExchange("fanout.exchange");
    }

    /**
     * 声明Binding,exchange与queue的绑定关系
     *
     * @return Binding
     */
    @Bean
    public Binding bindQ1() {
        return BindingBuilder.bind(fanoutQ1()).to(setFanoutExchange());
    }

}
